package com.javaee.ejb.session;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import com.javaee.ejb.entity.Message;

/**
 * Session Bean implementation class MessageManager
 */
@Stateless
public class MessageManager implements MessageManagerRemote {

    /**
     * Default constructor. 
     */
	@PersistenceContext
	EntityManager m_GestionnairesEntities;
    public MessageManager() {
        // TODO Auto-generated constructor stub
    }

	public void ajouterMessage(Message m_Message) {
		
		m_GestionnairesEntities.persist(m_Message);
		
	}
	
	public List<Message> getMessagesByConv(int idconv){
		return (List<Message>)(m_GestionnairesEntities.createNamedQuery("GetMessagesByConversation").setParameter("p_conv", idconv).getResultList());

		
	}

}